package com.legocms.web.controller.admin.cms;

import com.legocms.core.annotation.RequiresPermissions;
import com.legocms.core.vo.sys.SysPermissionCode;
import com.legocms.core.web.ViewResponse;
import com.legocms.web.controller.admin.AdminController;
import com.legocms.web.controller.admin.AdminView;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/content")
public class AdminCmsContentController extends AdminController {

    @GetMapping("/init")
    @RequiresPermissions(SysPermissionCode.CONTENT)
    public ViewResponse init() {
        return ViewResponse.ok(AdminView.CMS_CONTENT_LIST);
    }

    @GetMapping("/edit/{code}/{categoryCode}")
    @RequiresPermissions(SysPermissionCode.CONTENT_EDIT)
    public ViewResponse viewEdit(@PathVariable String code, @PathVariable String categoryCode) {
        return ViewResponse.ok(AdminView.CMS_CONTENT_EDIT).put("categoryCode", categoryCode).put("code", code);
    }

}
